<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>楼层销售情况分析</title>

		<script type="text/javascript" src="../lib/standalone-framework.js"></script>
		<script src="../lib/highcharts.js"></script>
		<script type="text/javascript">
			function getUrlParam(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
				var r = window.location.search.substr(1).match(reg);
				if (r != null)
					return unescape(r[2]);
				return null;
			}

			function get() {
				var projectEquals = getUrlParam("projectEquals");
				var salesDateEquals = getUrlParam("salesDateEquals");
				var dimensionTypeEquals = getUrlParam("dimensionTypeEquals");
				var request = new XMLHttpRequest();
				request.open("GET", encodeURI("getformatflow.thor?projectEquals=" + projectEquals + "&salesDateEquals=" + salesDateEquals + "&dimensionTypeEquals=" + dimensionTypeEquals));
				request.onreadystatechange = function() {
					if (request.readyState === 4 && request.status === 200) {
						document.getElementById("load").style.display="none";
						var response = JSON.parse(request.responseText);
						drawChart(response);
					}
				}
				request.send();
			}

			function drawChart(chartData) {
				
				var series = chartData.series;
				if(series.length == 0 ){
					var falg = chartData.flag;
					location.href ="reportnodata.thor?reporttype=flow&dimensionTypeEquals="+falg;
				}
				var chart = new Highcharts.Chart({
					chart : {
						renderTo : 'container',
						type : 'pie',
						plotBackgroundColor : null,
						plotBorderWidth : null,
						plotShadow : false
					},
					title : {
						text : chartData.chartRemark
					},
					tooltip : {
						pointFormat : '{series.name}: <b>{point.percentage:.1f}%</b>'
					},
					plotOptions : {
						pie : {
							allowPointSelect : true,
							cursor : 'pointer',
							dataLabels : {
								enabled : true
							},
							showInLegend : true
						}
					},
					series : series
				});
			}


			window.onload = get;
		</script>
	</head>
	<body>
		<div id="container" style="margin: 0 auto"></div>
		<div id="load"  align="center">
			<div id="center" style="position:absolute; left:0; top:120px; width:100%; height:100%; background-color:#FFFFFF; z-index:1000;">
				<table border="0">
					<tr>
						<td><span id="disp" >报表加载中,请等待...</span></td>
					</tr>
				</table>
			</div>
		</div>
	</body>
</html>